package com.xue.my.util.encrypt;
/**   
 * @Title: ByteSecurityCoder.java 
 * @Package com.xue.my.util.encrypt 
 * @Description: TODO
 * @author jimmy lovelyxuehanxin@163.com   
 * @date 2013-7-27 下午5:10:59 
 */
public class ByteSecurityCoder {

	/**
	 * 会话协议报文加解密密钥
	 */

	private byte securKey;

	/**
	 * 解密
	 * 
	 * @param bytes
	 * @return
	 */
	public  byte[] decode(byte[] bytes) {
		int len = bytes.length;
		for (int i = 0; i < len; i++) {
			bytes[i] = (byte) (bytes[i] ^ getSecurKey());
		}
		return bytes;
	}

	/**
	 * 加密
	 * 
	 * @param bytes
	 * @return
	 */
	public  byte[] encode(byte[] bytes) {
		int len = bytes.length;
		for (int i = 0; i < len; i++) {
			bytes[i] = (byte) (bytes[i] ^ getSecurKey());
		}
		return bytes;
	}

	public byte getSecurKey() {
		return securKey;
	}

	public void setSecurKey(byte securKey) {
		this.securKey = securKey;
	}
	
}
